package Year22_Month04.day05;

public class x的平方根 {
    public static int mySqrt(int x) {
        int left = 1;
        int right = x;
        while(left <= right){
            int mid = left + ((right - left) >> 1);
            int tmp = x / mid;
            if(tmp > mid){
                left = mid + 1;
            }else if(tmp < mid){
                right = mid - 1;
            }else{
                if(tmp * mid == x){return mid;}
                left = mid + 1;
            }
        }
        return left;
    }

}
